#include <iostream>
#include <unistd.h>
#include <stdio.h>
using namespace std;
int main()
{
  
  pid_t pid =fork();
  cout<<"i am father,running!n"<<endl;
  if(pid==0)
  {
    while(1)
    {
      cout<<"**********************************"<<endl;
      printf("i am child!,pid:%d,ppid:%d\n",getpid(),getppid());
      sleep(3);
    }
  }
  else if(pid>0)
  {
    int cnt=5;
    while(cnt--)
    {
      cout<<"i am father! i am alive!"<<endl;
      cout<<"**********************************"<<endl;
      printf("i am father!,pid:%d,ppid:%d\n",getpid(),getppid());
      sleep(3);
    }
   while(cnt==0)
   {
     cout<<"i am old father! i am die!  new father is bash!"<<endl;
     cout<<"**********************************"<<endl;
     sleep(3);
   }
  }
  return 0;
}
